<?php

/**
 * 文档服务
 * @author yuzy 2015-5-7
 */

namespace common\services\myhtsq;

use common\services\BaseService;
use common\error\ErrorCode;
use common\entities\ConfigEntity;
use common\repositories\myhtsq\DocumentRepository;

class DocumentService extends BaseService {

    /**
     * 构造函数
     */
    public function __construct() {
        
    }

    /**
     * 文档列表
     * @param string $businessId 业务id
     * @return array
     */
    public static function getDocumentListByBusinessId($businessId) {
        return DocumentRepository::getDocumentListByBusinessId($businessId);
    }	

    /**
     * 新增文档
     * @param \common\models\myhtsq\DocumentModel $documentModel
     * @return boolean|string 失败返回false，成功返回新增的文档Id
     */
    public function addDocument($documentModel) {
        if ($documentModel->validate()) {
            $result = DocumentRepository::addDocument($documentModel);
            if ($result === FALSE) {
                return $this->setAndReturn($entity->getErrCode());
            } else {
                return $result;
            }
        } else {
            return $this->setAndReturn(ErrorCode::ERR_DOCUMENT_FORM_VERIFY_FAIL);
        }
    }    
    
    public static function delDocumentById($docmentId){
        return DocumentRepository::delDocumentById($docmentId);
    }

    public static function delDocumentByBusinessId($businessId){
        return DocumentRepository::delDocumentByBusinessId($businessId);
    }
    
}
